package com.dangdang.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.dangdang.domain.User;

/**
 * 用户登录验证类
 * 
 * @author Wangpeihu
 * @team [Never give up]
 * @since JDK1.6(建议)
 * @date 2010-1-19
 */
public class ValidateUtils {

	/**
	 * 将用户状态设置成登录状态
	 * 
	 * @param request
	 * @param user
	 */
	public static void setLoginState(HttpServletRequest request, User user) {
		HttpSession session = request.getSession();
		session.setMaxInactiveInterval(3000);
		session.setAttribute(Constants.USER_KEY, user);
	}

	/**
	 * 将用户状态设置成登出状态
	 * 
	 * @param request
	 * @param user
	 */
	public static void setLogoutState(HttpServletRequest request) {
		HttpSession session = request.getSession();
		session.setMaxInactiveInterval(-1);
	}

}
